package initialize

import (
	"github.com/gin-gonic/gin"
	middlewares "kuangstudy-mall/apis/goods-web/middleawares"
	"kuangstudy-mall/apis/goods-web/router"
	"net/http"
)

func InitWebRouter() *gin.Engine {
	// 开始整合ginweb框架
	Router := gin.Default()

	Router.GET("/ping", func(context *gin.Context) {
		context.JSON(http.StatusOK, "pong")
	})

	// 配置跨域，身份鉴权
	Router.Use(middlewares.Cors())
	// 进行路由组的定义
	routerGroup := Router.Group("/v1")
	// 用户路由接口初始化
	router.InitGoodsRouter(routerGroup)
	return Router
}
